package com.tsing.bms.controller;

import com.tsing.bms.service.IMainTainService;
import com.tsing.bms.vo.req.IdReqVo;
import com.tsing.bms.vo.req.IdsReqVo;
import com.tsing.bms.vo.req.MainTainAddReqVo;
import com.tsing.bms.vo.req.MainTainUpdateReqVo;
import com.tsing.bms.vo.resp.MainTainRespVo;
import com.tsing.common.annotations.SystemLog;
import com.tsing.common.utils.ResultUtil;
import com.tsing.common.vo.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author TheTsing
 * @since 2021-03-29
 */
@Api(tags = "报修类目管理")
@RestController
@RequestMapping("/mainTain")
public class MainTainController {

    @Autowired
    private IMainTainService mainTainService;

    @PostMapping("/addMainTain")
    @ApiOperation(value = "新增报修类型")
    @SystemLog(description = "新增报修类型")
    public ResultData addMainTain(@Validated @RequestBody MainTainAddReqVo reqVo) {
        mainTainService.addMainTain(reqVo);
        return ResultUtil.success();
    }

    @DeleteMapping("/deleteMainTain")
    @ApiOperation(value = "删除报修类型")
    @SystemLog(description = "删除报修类型")
    public ResultData deleteMainTain(@Validated @RequestBody IdsReqVo reqVo) {
        mainTainService.deleteMainTain(reqVo);
        return ResultUtil.success();
    }

    @GetMapping("/getMainTain")
    @ApiOperation(value = "获取单个报修类型信息")
    @SystemLog(description = "获取单个报修类型信息")
    public ResultData<MainTainRespVo> getMainTain(@Validated IdReqVo reqVo) {
        return ResultUtil.success(mainTainService.getMainTain(reqVo));
    }

    @PutMapping("/updateMainTain")
    @ApiOperation(value = "修改报修类型信息")
    @SystemLog(description = "修改报修类型信息")
    public ResultData updateMainTain(@Validated @RequestBody MainTainUpdateReqVo reqVo) {
        mainTainService.updateMainTain(reqVo);
        return ResultUtil.success();
    }

    @GetMapping("/mainTainList")
    @ApiOperation(value = "报修类型列表")
    @SystemLog(description = "报修类型列表")
    public ResultData<List<MainTainRespVo>> mainTainList() {
        return ResultUtil.success(mainTainService.mainTainList());
    }

}
